package com.ruiwen.im.common.response;

import lombok.Data;

import java.io.Serializable;

/**
 * @author xukang
 * @date 2020-11-20 15:11
 */
@Data
public class IMCommonResponse <T>  implements Serializable {
    private Boolean success;
    //是否成功
    private Integer code;
    // 返回码
    private String message;
    //返回信息
    private T data;
    // 返回数据

    public IMCommonResponse() {
    }

    public IMCommonResponse(Boolean success, Integer code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    public IMCommonResponse(IMCommonResultCode resultCode) {
        this.success = resultCode.isSuccess();
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public IMCommonResponse(String message, IMCommonResultCode resultCode) {
        this.success = resultCode.isSuccess();
        this.code = resultCode.getCode();
        this.message = message;
    }

    public IMCommonResponse(IMCommonResultCode resultCode, T data) {
        this.data = data;
        this.success = resultCode.isSuccess();
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
    }

    public IMCommonResponse(Boolean success, Integer code, String message, T data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public IMCommonResponse setIMCommonResultCode(IMCommonResultCode resultCode) {
        this.success = resultCode.isSuccess();
        this.code = resultCode.getCode();
        this.message = resultCode.getMessage();
        return this;
    }

    public boolean isNill() {
        return false;
    }


}
